﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using LM.Negocio.Objetos;

namespace LM.Repositorios.Maps
{
    public class ModeloMap : EntityTypeConfiguration<Modelo>
    {
        public ModeloMap()
        {
            this.HasKey(m => m.Id);
            this.Property(m => m.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).HasColumnName("Id");

            this.Property(m => m.Codigo).HasColumnName("Codigo").IsRequired();
            this.Property(m => m.Descricao).HasColumnName("Descricao").IsRequired().HasMaxLength(100);
            //this.Property(m => m.MarcaId).HasColumnName("MarcaId");

            this.HasRequired(m => m.Marca)
                .WithMany(p => p.Modelos)
                .HasForeignKey(s => s.MarcaId);


            this.ToTable("MODELO");
        }
    }
}
